package com.ostrich.note.net;

import android.provider.Settings;
import android.util.Log;

import com.blankj.utilcode.util.SPUtils;

import java.io.IOException;

import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;


public class ParamInterceptor implements Interceptor {
    /**
     * 为所有的请求添加请求参数
     * @param chain
     * @return
     * @throws IOException
     */
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        HttpUrl url = request.url();

        String android_id = SPUtils.getInstance().getString("android_id");
        HttpUrl newUrl = url.newBuilder().addQueryParameter("equipment", android_id).build();
        Request newRequest = request.newBuilder().url(newUrl).build();
        return chain.proceed(newRequest);
    }

}
